<?php

// +----------------------------------------------------------------------
// | MyCentOS
// +----------------------------------------------------------------------
// | Copyright (c) 2014 http://www.mycentos.com, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 琥珀 <317559272@qqq.com><http://www.mycentos.com>
// +----------------------------------------------------------------------
// | @date  : 2015-03-05 14:13:54
// +----------------------------------------------------------------------
// | @Last Modified by:  琥珀
// +----------------------------------------------------------------------
// | @Last Modified time: 2015-03-14 18:11:22
// +-----------------------------------------------------------------------


/**
 * 系统操作日志
 * @authors 琥珀 (317559272@qq.com)
 */
namespace Admin\Controller;
use Think\Controller;
Class SyslogController extends AdminController
{
    function index() {
        $model = M('syslog');
        $searchname = I('searchname');
        if ($searchname) {
            $map['type|logname|username'] = array(array('like', '%' . $searchname . '%'), array('like', '%' . $searchname . '%'), array('like', '%' . $searchname . '%'), '_multi' => true);
        }
        $list = $this->lists($model, $map);
        $this->assign('list', $list);
        $this->assign('searchname', $searchname);
        $this->display();
    }
    public function del($ids = 0) {
        empty($ids) && $this->error('参数错误！');
        $ids = is_array($ids) ? implode(',', $ids) : $ids;
        $map['id'] = array('in', $ids);
        $res = M('syslog')->where($map)->delete();
        if ($res !== false) {
            $this->success('删除成功！');
        } else {
            $this->error('删除失败！');
        }
    }
    public function clear() {
        $res = M('syslog')->where('1=1')->delete();
        if ($res !== false) {
            $this->success('日志清空成功！');
        } else {
            $this->error('日志清空失败！');
        }
    }
}
?>